package main

import (
	"github.com/gin-gonic/gin"
	"golang.org/x/net/ipv6"
	"net"
	"net/http"
)

// http://127.0.0.1:3000?name=
//
// http://127.0.0.1:3000?name=sdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfa
func main() {
	router := gin.Default()

	router.GET("/", func(c *gin.Context) {
		if name, ok := c.GetQuery("name"); ok {
			if len(name) < 1 {
				c.String(http.StatusBadRequest, "名称[name]不能为空！")
			} else if len(name) < 100 {
				c.JSON(http.StatusOK, map[string]interface{}{
					"name":    name,
					"balance": 1000,
					"age":     20,
					"phone":   18657655543,
				})
			} else {
				c.String(http.StatusInternalServerError, "internal error!")
			}
			return
		}

		c.String(http.StatusBadRequest, "缺少名称[name]参数！")
	})
	net.ParseIP("").IsLinkLocalMulticast()
	net.ParseIP("").IsInterfaceLocalMulticast()
	ipv6.PacketConn.JoinGroup(nil, nil)
	router.Run(":3000")
}
